package ui.panels.primary.first;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.log4j.Logger;
import org.xml.sax.SAXException;

import com.cloudgarden.layout.AnchorLayout;

import ui.flowManager.FlowManagerImpl;
import ui.flowManager.expirimentProperties.ExperimentProperties;
import ui.panels.Panel;
import ui.panels.PanelTypes;
import ui.panels.PanelTypes.PanelType;
import ui.panels.commands.NextCommand;
import ui.panels.commands.OpenXMLExperimentCommand;
import ui.panels.commands.ReadFromFileCommand;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
 * @author vladimir && alon
 * The first panel of the GUI
 * The purpose of the panel is choosing:
 * 		- Manual creating
 * 		- From file
 */
public class FirstPanel extends Panel {

	 private JButton 	manual;
	 private JButton 	fromFile;

	Logger log = Logger.getLogger(this.getClass());
	
	/*** Set a special look for the window*/
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * CTOR
	 */
	public FirstPanel(HashMap<String, String> map)
	{
		super();
	}

	
	/**
	 *
	 */
	@Override
	public PanelType getPanelType() {
		// TODO Auto-generated method stub
		return null;
	}

	
	@Override
	public void show(ExperimentProperties props) {

		 log.debug("started show in First Panel - Choice of Manual/From file");
		 
		 try
		 {
			 AnchorLayout thisLayout = new AnchorLayout();
			 setLayout(thisLayout);
			 setPreferredSize(new Dimension(720, 480));

			 Font font = new Font(Font.MONOSPACED, Font.TRUETYPE_FONT, 20);
			 //the manual button			 
			 manual = new JButton("Enter the data manually");
			 manual.setFont(font);
			 //color for the button
			 manual.setBackground(Color.DARK_GRAY);
			 manual.setForeground(Color.WHITE);
			 this.add(manual, new AnchorConstraint(213, 731, 326, 267, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));	
			 manual.setPreferredSize(new java.awt.Dimension(334, 54));
			 
			 //from a file button
			 
			 fromFile = new JButton();
			 this.add(fromFile, new AnchorConstraint(521, 731, 634, 267, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
			 fromFile.setText("Load Experiment from file");
			 fromFile.setBackground(Color.DARK_GRAY);
			 fromFile.setFont(font);
			 fromFile.setForeground(Color.WHITE);
			 fromFile.setPreferredSize(new java.awt.Dimension(334, 54));
					 
				
			 //  ******		add listeners	 ******
			 log.debug("Adding listeners");
			 ActionList actionListener = new ActionList(this);
			 manual.addActionListener(actionListener);
			 fromFile.addActionListener(actionListener);
		 }
		//end of try
		 catch (Exception e) {
				e.printStackTrace();
		}
		 		 
	}

	
	
	public JButton getManual() {
		return manual;
	}


	public JButton getFromFile() {
		return fromFile;
	}



 
	@Override
	public void setFromPropertiesConfig(HashMap<String, String> map) {
		// nothing to set
	}

}
